package Code;
 
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.terrain.geomipmap.TerrainLodControl;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.util.SkyFactory;
 
/** Sample 4 - how to trigger repeating actions from the main update loop.
 * In this example, we make the player character rotate. */
public class Main extends SimpleApplication{
    public Character oto = new Character();
    public Physics physics = new Physics();
 
    public static void main(String[] args){
        Main app = new Main();
        app.start();
    }
 
 
    @Override
    public void simpleInitApp() {
    //flyCam.setMoveSpeed(50);
    flyCam.setEnabled(false);
    viewPort.setBackgroundColor(ColorRGBA.Blue);
    
    physics.initialize();
    stateManager.attach(physics.bulletAppState);

    oto.load(inputManager, assetManager, rootNode, cam);
    
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());
    rootNode.addLight(dl);
    
    Terrain startIsland = new Terrain();
    TerrainQuad terrain = startIsland.load(assetManager);
    rootNode.attachChild(terrain);
    TerrainLodControl control = new TerrainLodControl(terrain, cam);
    terrain.addControl(control);
    physics.loadTerrainCollision(terrain);
    physics.loadCharacterCollision(oto);
    
    }
 
    /* This is the update loop */
    @Override
    public void simpleUpdate(float tpf) {
        oto.update();
        //cam.lookAt(oto.player.getLocalTranslation(), new Vector3f(0,1,0));
    }
}